package cn.kingshion.reflectiong;

/**
 * 类加载器
 */
public class Test05 {

    public static void main(String[] args) throws ClassNotFoundException {
        // 系统类加载器 又叫 应用程序类加载器
        ClassLoader sysclassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(sysclassLoader);

        // 扩展类加载器
        ClassLoader exClass = sysclassLoader.getParent();
        System.out.println(exClass);

        // 引导类加载器
        ClassLoader rtClass = exClass.getParent();
        System.out.println(rtClass);

        // 测试当前类由那个加载器加载
        Class aClass = Class.forName("cn.kingshion.reflectiong.Test05");
        ClassLoader userClass = aClass.getClassLoader();
        System.out.println(userClass);

        // 如何获得系统类加载器的加载路径
        System.out.println(System.getProperty("java.class.path"));
        /*
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\deploy.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\access-bridge-64.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\cldrdata.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\dnsns.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jaccess.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\localedata.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\nashorn.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunec.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunjce_provider.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunmscapi.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunpkcs11.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\zipfs.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\javaws.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\jce.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfr.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfxswt.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\jsse.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\management-agent.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\plugin.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\resources.jar;
        C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar;
        E:\JavaStudy\out\production\Java-Annotation;
        C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.3\lib\idea_rt.jar

         */
    }
}
